package com.library.weiget;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.jtjrenren.android.taxi.driver.R;
import com.library.utils.DensityUtils;

/**
 * Created by Administrator on 2016/5/3.
 */
public class UpAppDlg extends Dialog {
    private TextView tv_versionno, tv_versionsize, tv_content, tv_cancleup, tv_postup, tv_cancledown;
    private LinearLayout ll_up, ll_pro;
    private ProgressBar pb;

    public UpAppDlg(Context context) {
        super(context);
        initViews();
    }

    public UpAppDlg(Context context, int themeResId) {
        super(context, themeResId);
        initViews();
    }

    protected UpAppDlg(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);

        initViews();
    }

    private void initViews() {
        View view = View.inflate(getContext(),
                R.layout.dlg_appversion, null);

        tv_versionno = (TextView) view.findViewById(R.id.versiondlg_versionno);
        tv_versionsize = (TextView) view.findViewById(R.id.versiondlg_versiosize);
        tv_content = (TextView) view.findViewById(R.id.versiondlg_versioncontent);
        tv_cancleup = (TextView) view.findViewById(R.id.versiondlg_versioncon_cancle);
        tv_postup = (TextView) view.findViewById(R.id.versiondlg_versioncon_post);
        tv_cancledown = (TextView) view.findViewById(R.id.versiondlg_versiondown_cancle);

        ll_pro = (LinearLayout) view.findViewById(R.id.versiondlg_version_down);
        ll_up = (LinearLayout) view.findViewById(R.id.versiondlg_versioncon);

        pb = (ProgressBar) view.findViewById(R.id.versiondlg_versionprecss);

        setContentView(view);

        getWindow().setLayout(DensityUtils.dip2px(getContext(), 282), DensityUtils.dip2px(getContext(), 205));
    }

    public void setCommon(String no, String size, String content, View.OnClickListener cancle, View.OnClickListener post, View.OnClickListener downcancle) {
        tv_versionno.setText(no);
        tv_versionsize.setText(size);
        tv_content.setText(content);

        tv_postup.setOnClickListener(post);
        tv_cancleup.setOnClickListener(cancle);
        tv_cancledown.setOnClickListener(downcancle);
    }

    public void showProcess() {
        ll_pro.setVisibility(View.VISIBLE);
        ll_up.setVisibility(View.GONE);
        tv_cancledown.setVisibility(View.VISIBLE);
    }

    public void refreshProcess(int process){
        pb.setProgress(process);
    }
}
